package com.ruoyi.asset.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.asset.domain.AstSiteRecord;
import com.ruoyi.asset.service.IAstSiteRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站点工作记录Controller
 * 
 * @author xunzhe
 * @date 2024-06-17
 */
@Controller
@RequestMapping("/asset/astSiteRecord")
public class AstSiteRecordController extends BaseController
{
    private String prefix = "asset/astSiteRecord";

    @Autowired
    private IAstSiteRecordService astSiteRecordService;

    @RequiresPermissions("asset:astSiteRecord:view")
    @GetMapping()
    public String astSiteRecord()
    {
        return prefix + "/astSiteRecord";
    }

    /**
     * 查询站点工作记录列表
     */
    @RequiresPermissions("asset:astSiteRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AstSiteRecord astSiteRecord)
    {
        startPage();
        List<AstSiteRecord> list = astSiteRecordService.selectAstSiteRecordList(astSiteRecord);
        return getDataTable(list);
    }

    /**
     * 导出站点工作记录列表
     */
    @RequiresPermissions("asset:astSiteRecord:export")
    @Log(title = "站点工作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AstSiteRecord astSiteRecord)
    {
        List<AstSiteRecord> list = astSiteRecordService.selectAstSiteRecordList(astSiteRecord);
        ExcelUtil<AstSiteRecord> util = new ExcelUtil<AstSiteRecord>(AstSiteRecord.class);
        return util.exportExcel(list, "站点工作记录数据");
    }

    /**
     * 新增站点工作记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存站点工作记录
     */
    @RequiresPermissions("asset:astSiteRecord:add")
    @Log(title = "站点工作记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AstSiteRecord astSiteRecord)
    {
        return toAjax(astSiteRecordService.insertAstSiteRecord(astSiteRecord));
    }

    /**
     * 修改站点工作记录
     */
    @RequiresPermissions("asset:astSiteRecord:edit")
    @GetMapping("/edit/{recordId}")
    public String edit(@PathVariable("recordId") Long recordId, ModelMap mmap)
    {
        AstSiteRecord astSiteRecord = astSiteRecordService.selectAstSiteRecordByRecordId(recordId);
        mmap.put("astSiteRecord", astSiteRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存站点工作记录
     */
    @RequiresPermissions("asset:astSiteRecord:edit")
    @Log(title = "站点工作记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AstSiteRecord astSiteRecord)
    {
        return toAjax(astSiteRecordService.updateAstSiteRecord(astSiteRecord));
    }

    /**
     * 删除站点工作记录
     */
    @RequiresPermissions("asset:astSiteRecord:remove")
    @Log(title = "站点工作记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(astSiteRecordService.deleteAstSiteRecordByRecordIds(ids));
    }
}
